package com.bdqn.sl5;

import com.bdqn.ch05.jd.Equip;
import com.bdqn.ch05.sl.sl1.pojo.User;
import com.bdqn.ch05.sl.sl1.service.UserService;
import com.bdqn.ch05.sl.sl3.HellSpring;
import com.bdqn.ch05.sl.sl7.Printer;
import com.bdqn.ch06.sz.sz1.Show;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloSpring {
@Test
public void test(){
    ApplicationContext context = new ClassPathXmlApplicationContext("Spring-config.xml");
    HellSpring helloSpring = (HellSpring) context.getBean("helloSpring");
    helloSpring.print();
}

@Test
    public void printerTest(){
    ApplicationContext context = new ClassPathXmlApplicationContext("Spring-config.xml");
    Printer printer = (Printer) context.getBean("printer");
    String content = "歌词太长不想写";
    printer.print(content);
}
    @Test
    public void aopTest(){
       ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) context.getBean("userService");
        User user = new User();
        user.setId(1);
        user.setUsername("test");
        user.setPassword("123456");
        user.setEmail("123456@163.com");
        userService.save(user);

    }
    @Test
    public void show(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Show show = (Show) context.getBean("show");
        show.show();
    }
    @Test
    public void shenJi() {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        Equip equip = (Equip) ctx.getBean("lanMoRing");
        System.out.println(equip);
    }

}
